<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------

namespace app\helper;

/**
 *
 * 数组函数
 */
class Arr
{
    public static function ids(array $list, string $field = 'item_id', string $items = 'items'){
        $ids = [];
        foreach($list as $row){
            $ids = array_merge($ids, array_column($row[$items], $field));
        }
        return $ids;
    }
    // 
    public static function merge(array $list, array $views, string $key = 'item_id'){
        foreach($list as $k => $row){
            isset($row[$key]) && ($list[$k] += $views[$row[$key]]);
        }
        return $list;
    }
}
